package com.lianniu.web.baseService.user.service.impl;

import javax.annotation.Resource;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSON;
import com.lianniu.web.base.BaseResult;
import com.lianniu.web.baseService.user.dao.ISupplyDao;
import com.lianniu.web.baseService.user.model.Supply;
import com.lianniu.web.baseService.user.service.ISupplyService;
@Service
public class SupplyServiceImpl implements ISupplyService{
	
	private final static Logger logger = Logger.getLogger(SupplyServiceImpl.class);		

	
	@Resource
	ISupplyDao supplyDao;
	@Override
	public BaseResult updateId(Supply supply) {
		logger.info("updateSupplyById begin");
	    logger.info("updateSupplyById: update data check begin");
	    logger.info("updateSupplyById  supply:" +JSON.toJSONString(supply.getUserId()));
	    /*BaseResult baseResult;
	    if(StringUtil.isEmpty(supply.getSupplyName())){
	    	
	    	baseResult = BaseResult.fail(ErrorCode.ParaCheckErrorRetCode, ErrorCode.ParaCheckErrorRetInfo);
	    	return baseResult;
	    }
	    if(StringUtil.isEmpty(supply.getLawer())){
         baseResult = BaseResult.fail(ErrorCode.ParaCheckErrorRetCode, ErrorCode.ParaCheckErrorRetInfo);	    	
	    }*/
	    logger.info("updateSupplyById: update data check end");
		return BaseResult.success(supplyDao.updateById(supply));
	}
	@Override
	public BaseResult addSupply(Supply supply) {
	    logger.info("addSupply begin");
	    logger.info("addSupply: input data check begin");
	    logger.info("addSupply dictType:" +JSON.toJSONString(supply));
	    logger.info("addSupply: input data check end");
	    
	    return BaseResult.success(supplyDao.addSupply(supply));

	}
	@Override
	public BaseResult getSupplyId(String id) {
		Supply supply = supplyDao.getSupplyById(id);
	    return BaseResult.success(supply);
	}
	
	 @Override
	    public BaseResult selectByUsersId(String id) {
	        logger.info("selectByUsersId begin");
	        logger.info("selectByUsersId id:"+id);
	        return BaseResult.success(supplyDao.selectByUsersId(id));
	    }
	 
    @Override
    public BaseResult updateSupplyByUserId(String userId) {
      logger.info("updateSupplyByUserId begin");
      logger.info("updateSupplyByUserId userId" + userId);
        return BaseResult.success(supplyDao.updateSupplyByUserId(userId));
    }

}
